package cn.com.tarotframework.server.oauth.service.impl;


import cn.com.tarotframework.server.oauth.dto.LoginDto;
import cn.com.tarotframework.server.oauth.mapper.IUserMapper;
import cn.com.tarotframework.server.oauth.po.UserPo;
import cn.com.tarotframework.server.oauth.service.ILoginService;
import cn.com.tarotframework.server.oauth.vo.LoginVo;
import com.mybatisflex.core.query.QueryChain;
import org.springframework.stereotype.Service;

/**
 * copyright (C), 2022, 塔罗牌基础架构
 *
 * @program tarot-core
 * @description 用户信息接口实现类
 * @author Jiang Xincan
 * @version 0.0.1
 * @create 2024/01/20 18:54
 **/
@Service
public class LoginServiceImpl implements ILoginService {

    private final IUserMapper userMapper;

    public LoginServiceImpl(IUserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public LoginVo in(LoginDto loginDto) {

        return QueryChain.of(userMapper).select()
                .from(UserPo.class)
                .where(UserPo::getAccount).eq(loginDto.getAccount())
                .and(UserPo::getPassword).eq(loginDto.getPassword())
                .oneAs(LoginVo.class);

    }

}